package com.hgw.Demo05_FacadePattern.examples;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * Data time:2021/12/15 11:49
 * StudentID:2019112118
 * Author:hgw
 * Description: 文件保密类，充当子系统类
 */
public class FileWriter {

    public void write(String encryptStr, String fileNameDes) {
        System.out.println("保存密文，写入文件.");

        try {
            FileOutputStream outFS = new FileOutputStream(fileNameDes);
            outFS.write(encryptStr.getBytes());
            outFS.close();
        } catch (FileNotFoundException e) {
            System.out.println("文件不存在！");
        } catch (IOException e) {
            System.out.println("文件操作错误！");
        }
    }
}
